﻿using EfInfra;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EfLearn
{
    internal class DemoContextBuilder : IDesignTimeDbContextFactory<DemoContext>
    {
        public DemoContext CreateDbContext(string[] args)
        {
            // 此处写死，简单一点，读取配置文件比较复杂，只是为了迁移数据库
            string connStr = "Host=127.0.0.1;Port=5432;Database=eflearn;User ID=postgres;Password=sa*123;Pooling=true;MinPoolSize=10;MaxPoolSize=50;";
            DbContextOptionsBuilder<DemoContext> builder = new();
            builder.UseNpgsql(connStr);
            var ctx = new DemoContext(builder.Options);
            return ctx;
        }
    }
}
